﻿using System;
using System.IO;

namespace Terraria.ModLoader.IO
{
	// Token: 0x020002C1 RID: 705
	internal static class FontCacheIO
	{
		// Token: 0x06001BAB RID: 7083 RVA: 0x00431528 File Offset: 0x0042F728
		internal static bool FontCacheAvailable(string fontCachePath)
		{
			return File.Exists(FontCacheIO.FontCachePath + Path.DirectorySeparatorChar.ToString() + fontCachePath);
		}

		// Token: 0x06001BAC RID: 7084 RVA: 0x00431558 File Offset: 0x0042F758
		internal static void DeleteIfOlder(string modFilename, string fontCacheFilename)
		{
			FileInfo fileInfo = new FileInfo(modFilename);
			DirectoryInfo directoryInfo = Directory.CreateDirectory(FontCacheIO.FontCachePath);
			foreach (FileInfo fileInfo2 in directoryInfo.EnumerateFiles(Path.GetFileNameWithoutExtension(fontCacheFilename.Substring(0, fontCacheFilename.LastIndexOf('_'))) + "_*.xnb"))
			{
				if (fileInfo2.Name == fontCacheFilename)
				{
					if (fileInfo2.LastWriteTime < fileInfo.LastWriteTime)
					{
						fileInfo2.Delete();
					}
				}
				else
				{
					fileInfo2.Delete();
				}
			}
		}

		// Token: 0x04001892 RID: 6290
		public static readonly string FontCachePath = string.Concat(new string[]
		{
			"Content",
			Path.DirectorySeparatorChar.ToString(),
			"Fonts",
			Path.DirectorySeparatorChar.ToString(),
			"ModFonts"
		});
	}
}
